module.exports = file => {
  try {
    if (file.endsWith('/index')) {
      return require(`@/views/${file}.vue`).default
    } else {
      return require(`@/views/${file}/index.vue`).default
    }
  } catch (e) {
    console.error(`无法加载组件: @/views/${file}/index.vue`, e)
    
    try {
      return require(`@/views/${file}.vue`).default
    } catch (e2) {
      console.error(`无法直接加载组件: @/views/${file}.vue`, e2)
      return require('@/views/404.vue').default
    }
  }
}
